package com.gibs.peixunapi.excepiton;

import com.gibs.peixunapi.enums.ResultEnum;

/**
 * @author liangjiawei
 * @date 2020/08/20/11:14
 * @Version 1.0
 * @Description:
 */
public class BaseException extends RuntimeException {
    private Integer code;

    private String msg;

    public BaseException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
    }
    public BaseException() {
        super();
    }

    public BaseException(ResultEnum resultEnum, Throwable cause) {
        super(resultEnum.getCode().toString(), cause);
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg()+":"+cause.getMessage();
    }

    public BaseException(String errorMsg) {
        super(errorMsg);
        this.msg = errorMsg;
    }

    public BaseException(Integer errorCode, String errorMsg) {
        super(errorMsg+"");
        this.code = errorCode;
        this.msg = errorMsg;
    }

    public BaseException(Integer errorCode, String errorMsg, Throwable cause) {
        super(errorMsg, cause);
        this.code = errorCode;
        this.msg = errorMsg+":"+cause.getMessage();
    }
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
